package com.hx.pojo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
//作用等同于<bean id="foodType" class="com.hx.pojo.FoodType"></bean>
public class FoodType {
    @Value("20")
    private Integer id;
    @Value("赵四")
    private String name;

    /**
     * 生命周期相关
     * @return
     */
//    @PostConstruct
//    public void init() {
//        System.out.println("FoodType init.....");
//    }
//    @PreDestroy
//    public void destroy() {
//        System.out.println("FoodType destroy.....");
//    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    @Override
    public String toString() {
        return "FoodType{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }
}
